Documentation

UserController extends AbstractController
in package

Table of Contents

Properties

$encoder  : UserPasswordHasherInterface

Methods

__construct()  : mixed
userCreateAction()  : Response
Creates a new user.
userDeleteAction()  : Response
Deletes a user.
userEditAction()  : Response
Edit a user.
usersListAction()  : Response
Retrieves a list of users.

Properties

Methods

__construct()

public __construct(UserPasswordHasherInterface $encoder) : mixed
Parameters
$encoder : UserPasswordHasherInterface

userCreateAction()

Creates a new user.

public userCreateAction(EntityManagerInterface $emi, Request $request) : Response

This method is responsible for creating a new user and persisting it to the database. It handles the form submission and validation, sets the user's password and roles, and redirects the user to the appropriate page based on their role.

Parameters
$emi : EntityManagerInterface

The entity manager interface.

$request : Request

The request object.

Return values
Response

The response object.

userDeleteAction()

Deletes a user.

public userDeleteAction(User $user, EntityManagerInterface $emi) : Response

This method is used to delete a user from the system. Only users with the ROLE_ADMIN role are allowed to perform this action.

Parameters
$user : User

The user to be deleted.

$emi : EntityManagerInterface

The entity manager interface.

Return values
Response

The response object.

userEditAction()

Edit a user.

public userEditAction(User $user, Request $request, EntityManagerInterface $emi) : Response

This method allows editing a user's information, such as username, email, and password. Only authenticated users can access this page. If the user is not logged in, they will be redirected to the homepage. If the user is not an admin and is trying to edit another user's information, they will be redirected to the homepage. After successfully editing the user, the user will be logged out and redirected to the admin page if they are an admin, or to the login page if they are a regular user.

Parameters
$user : User

The user to edit.

$request : Request

The request object.

$emi : EntityManagerInterface

The entity manager.

Return values
Response

The response object.

usersListAction()

Retrieves a list of users.

public usersListAction(EntityManagerInterface $emi) : Response
Parameters
$emi : EntityManagerInterface

The entity manager interface.

Return values
Response

The response object.


        
On this page

Search results